class P10922_39643 {

    public static void main(String[] args) {
    	String x = readLn();
    	while (!"0".equals(x)) {
    		process(x);
    		x = readLn();
    	}
    }


	private static void process( String x ) {

		try {
			if (x.equals("9")) 
			 System.out.println("9 is a multiple of 9 and has 9-degree 1.");
			else System.out.println(x + " is a multiple of 9 and has 9-degree " + calc(x) + ".");
		} catch (Exception e) {
			System.out.println(x + " is not a multiple of 9.");
		}
		
	}


	private static int calc( String x ) {
		int length = x.length();
		if (length == 1) {
			if ("9".equals(x)) return 0;
			else throw new RuntimeException();
		} else {
			int value = 0;
			for (int k = 0; k < length; k++) {
				value = value + (x.charAt(k) - '0');
			}
			return 1 + calc(value + "");
		}
	}


	static String readLn() {
        String newLine = System.getProperty("line.separator");
        StringBuffer buffer = new StringBuffer();
        int car = -1;
        try {
            car = System.in.read();
            while ((car > 0) && (car != newLine.charAt(0))) {
                buffer.append((char)car);
                car = System.in.read();
            }
            if (car == newLine.charAt(0))
            System.in.skip(newLine.length() - 1);
        } catch (java.io.IOException e) { return (null);}
        if ((car < 0) && (buffer.length() == 0)) return (null);
        return (buffer.toString()).trim();
    }

}